#ifndef _ZMIPC_PROTO_H_
#define _ZMIPC_PROTO_H_

#include "vpi.h"

#define ZMIPC_PROTO_TYPE 0x8008
#define ZMIPC_PROTO_NAME "zmipc"
#define ZMIPC_PROTO_VER  "2.1.4"

extern const sproto_header * zmipc_default_header;

//=============================================================================
#define IS_ZMIPC_DOWNCMD(cmd) \
	(((cmd)>0x00&&(cmd)<0xFF) || ((cmd)>0xFF00&&(cmd)<0xFFFF))
#define IS_ZMIPC_UPCMD(cmd) \
	(((cmd)>0x10&&(cmd)<0xFF) || ((cmd)>0xFF00&&(cmd)<0xFFFF))

#define ZMIPC_TOP_1 0x40
#define ZMIPC_TOP_2 0x21
#define ZMIPC_END   0x23

// total cmds: 8+7 + 30+26 = 71(in protocol)
//--------------------------------------------------------------------
/*
 * client --> device : down cmd, 8 + 30 = 38
 */
/* video and audio data transport cmds: 0x01-0x08 */
#define SOCKET_CLIENT_LOGIN     0x01 //- request login device
#define SOCKET_DATA_TYPE		0x02
#define SOCKET_GET_LOG			0x03
#define SOCKET_REQ_SEND_AUDIO	0x04
#define SOCKET_SEND_AUDIO		0x05
#define SOCKET_STOP_RECV_AUDIO	0x06
#define SOCKET_MULTIWAY_DATA	0x07  //request multiway data-transfer 
#define SOCKET_GET_CLINET_TYPE	0x08

/* control cmds: 0x41-0x46,0x48-0x50,0xA0-0xB4 */
#define SOCKET_GET_ALARM_STATUS			0x41
#define SOCKET_CLEAN_ALARM_STATUS		0x42
#define SOCKET_REQUEST_SD_TOP			0x43
#define SOCKET_REQUEST_SD_FILE_INFO		0x44
#define SOCKET_DEL_SD_FILE				0x45
#define SOCKET_PTZ_CTRL					0x46

#define SOCKET_REQUEST_SD_FILE_DATA		0x48
#define SOCKET_IMAGE_VALUE				0x49
#define SOCKET_VIDEO_VALUE				0x50

#define SOCKET_RECODER_VALUE 			0xA0
#define SOCKET_OSD_VALUE				0xA1
#define SOCKET_NET_VALUE				0xA2
#define SOCKET_WIFI_VALUE				0xA3
#define SOCKET_WIFI_LIST				0xA4
#define SOCKET_DEFAULT_SET				0xA5
#define SOCKET_TIME_SET					0xA6
#define SOCKET_SET_ALARM_MD				0xA7
#define SOCKET_HOLD_HEART				0xA8 //-- heart cmd to hold connection
#define SOCKET_SET_ALARM_REC			0xA9
#define SOCKET_SET_ALARM_EMAIL			0xAA
#define SOCKET_SET_ALARM_FTP			0xAB
#define SOCKET_SET_ALARM_SNAP			0xAC
#define SOCKET_SET_ALARM_IO				0xAD
#define SOCKET_REBOOT					0xAE
#define SOCKET_EMAIL_TEST				0xAF
#define SOCKET_SET_CODE					0xB0
#define SOCKET_GET_NATTYPE				0xB1
#define SOCKET_SET_DISPALY				0xB2// -- set display information 
#define SOCKET_IO_CONTROL				0xB3// -- IO control cmd
#define SOCKET_MINOR_STREAM				0xB4 
#define SOCKET_SET_WIFI_IN_AP			0xFF01
#define SOCKET_RES_SET_WIFI_IN_AP		0xFF11
#define SOCKET_SDCARD_VALUE				0xFFA0 //lhq
#define SOCKET_DEV_VERSION				0xFFB6 //lhq
/*
 * // register reponse cmd, in p2p protocol 
 * #define SOCKET_SET_SERVERINFO	    0xD3 
 */
#define SOCKET_GET_PASSWD				0xD7 // unkown

//--------------------------------------------------------------------
/* 
 * device --> client: up cmd, 7 + 26 = 33
 */
/* video and audio data transport cmds: 0x11-0x17 */
#define SOCKET_RE_CLIENT_LOGIN 		0x11
#define SOCKET_RES_DATA				0x12 //-- response data
#define SOCKET_UPLOAD_LOG_FILE		0x13 //upload log files,add new macro
#define SOCKET_RESPONS_AUDIO_DATA	0x14
#define SOCKET_RES_STOP_SPEECH 		0x15 //-- stop voice-intercom
#define SOCKET_SEND_OCX_VERSION		0x16
#define SOCKET_RE_CLIENT_TYPE  		0x17

/* control cmds: 0x51-0x52,0x54-0x58,0xC0-0xD0,0xD6-0xD7 */
/* add ... */
#define SOCKET_REPORT_ALARM_STATUS		0x51 
#define SOCKET_RE_FILELIST				0x52 
#define SOCKET_RE_FILEINFO				0x54 
#define SOCKET_RE_FILEDATA				0x55 
#define SOCKET_RE_DELFILE				0x56 
/* end add. */

#define SOCKET_RE_PTZ_CMD				0x57 // add new macro
#define SOCKET_RE_IMAGE					0x58

#define SOCKET_RE_VIDEO					0xC0
#define SOCKET_RE_RECODER				0xC1
#define SOCKET_RE_OSD					0xC2
#define SOCKET_RE_NET					0xC3
#define SOCKET_RE_WIFI					0xC4
#define SOCKET_RE_WIFI_LIST				0xC5
#define SOCKET_RE_DEFAULT_SET			0xC6
#define SOCKET_RE_TIME_SET				0xC7
#define SOCKET_RE_MD_SET				0xC8
#define SOCKET_RE_POLICE_RECODE_SET		0xC9
#define SOCKET_RE_POLICE_EMAILE_SET		0xCA
#define SOCKET_RE_POLICE_FTP_SET		0xCB
#define SOCKET_RE_POLICE_PICTURE_SET	0xCC
#define SOCKET_RE_POLICE_IO_SET	   		0xCD
#define SOCKET_RE_MAILTEST				0xCE //-- response mail test result
#define SOCKET_RE_SET_CODE				0xCF
#define SOCKET_RE_NATTYPE				0xD0
#define SOCKET_RE_SDCARD				0xFFA1 //lhq
#define SOCKET_RE_DEV_VERSION			0xFFB7 //lhq
/* 
 * //register cmd,in p2p proto
 * #define SOCKET_GET_SERVERINFO  		0xD2  
 */
#define SOCKET_RE_IO_CONTROL			0xD6 //-- IO control cmd reponse
#define SOCKET_RE_MINOR_STREAM			0xD7 // response to 0xB4 cmd
#define SOCKET_SEND_PASSWD				0xD8 // unkown

//----------------------------------------------------------------
// Macros Define about data-desciprtions in cmd
// data type
#define ZMIPC_DT_NONE  0x00
#define ZMIPC_DT_VIDEO 0x01
#define ZMIPC_DT_AUDIO 0x02
#define ZMIPC_DT_VAMIX 0x03
#define ZMIPC_DT_MINOR 0x04
// log type
#define ZMIPC_LOG_MIAN 0x01
#define ZMIPC_LOG_LIVE 0x02
#define ZMIPC_LOG_WEB  0x03
#define ZMIPC_LOG_UPDATE 0x04
#define ZMIPC_LOG_CGI  0x05
// client type
#define ZMIPC_CLI_PC 	0xD1
#define ZMIPC_CLI_PHONE 0xD2
#define ZMIPC_CLI_EMBED 0xD3
// video encode
#define ZMIPC_VENC_MJPEG 0x01
#define ZMIPC_VENC_H264  0x02
// audio encode
#define ZMIPC_AENC_G711A 0x01
#define ZMIPC_AENC_G711U 0x02
#define ZMIPC_AENC_ADPCM 0x03
// const bitrate or variable bitrate
#define ZMIPC_VBR 0x00
#define ZMIPC_CBR 0x01
// login response value
#define ZMIPC_RES_OK 			0x01
#define ZMIPC_RES_TOOMANY_USER 	0x02
#define ZMIPC_RES_FAULT 		0x03
#define ZMIPC_RES_CODE_ERR 		0x04
#define ZMIPC_RES_VIDEO_RACE 	0x05
#define ZMIPC_RES_VIDEO_REFUSE 	0x06
// reponse to audio speech
#define ZMIPC_RES_AUDIO_AGREE 	0x05
#define ZMIPC_RES_AUDIO_REFUSE	0x06
// action type
#define ZMIPC_ACT_GET	0x01 // except: 0xB4 is 0x00, modify to uniform
#define ZMIPC_ACT_SET 	0x02 // except: 0xB4 is 0x01
#define ZMIPC_ACT_DEF	0x03
// switch flag
#define ZMIPC_FLAG_OFF 	0x00
#define ZMIPC_FLAG_ON	0x01
// stream channel or type
#define ZMIPC_STREAM_MAJOR 0x01
#define ZMIPC_STREAM_MINOR 0x02
// resolution type
#define ZMIPC_PIXEL_D1	0x00
#define ZMIPC_PIXEL_VGA 0x01
#define ZMIPC_PIXEL_CIF 0x02
#define ZMIPC_PIXEL_720P 0x03
#define ZMIPC_PIXEL_1080P 0x04
// multiway channel number
#define ZMIPC_MULTI_CHN1 0x01
#define ZMIPC_MULTI_CHN2 0x02
#define ZMIPC_MULTI_CHN3 0x03
#define ZMIPC_MULTI_CHN4 0x04
// sd file list type
#define ZMIPC_SD_DIRLIST  0x01
#define ZMIPC_SD_FILELIST 0x02
// ptz control cmds
#define ZMIPC_PTZ_UP			0x01
#define ZMIPC_PTZ_DOWN			0x02
#define ZMIPC_PTZ_LEFT			0x03
#define ZMIPC_PTZ_RIGHT			0x04
#define ZMIPC_PTZ_RIGHT_UP		0x05
#define ZMIPC_PTZ_RIGHT_DOWN	0x06
#define ZMIPC_PTZ_LEFT_UP		0x07
#define ZMIPC_PTZ_LEFT_DOWN		0x08
#define ZMIPC_PTZ_CRUISE_A 		0x09
#define ZMIPC_PTZ_CRUISE_H		0x0A// left to right
#define ZMIPC_PTZ_CRUISE_V		0x0B// up to down
#define ZMIPC_PTZ_FOCUS_NEAR	0x0C
#define ZMIPC_PTZ_FOCUS_FAR		0x0D
#define ZMIPC_PTZ_SET_PRESET	0x0E
#define ZMIPC_PTZ_GOTO_PRESET   0x0F
#define ZMIPC_PTZ_STOP 			0x10
#define ZMIPC_PTZ_AB_CRUISE  	0x11
// ADD ,unsupported in protocol now
#define ZMIPC_PTZ_TURN_ANGLE 	0x12
#define ZMIPC_PTZ_TURN_STEPS	0x13

// image mirror setting type
#define ZMIPC_MIRROR_DEF	0x00
#define ZMIPC_MIRROR_VER	0x01
#define ZMIPC_MIRROR_HOR	0x02
#define ZMIPC_MIRROR_ALL	0x03

/* wifi data type macros */
// group type
#define ZMIPC_WIFI_GROUP_CCMP  0x01
#define ZMIPC_WIFI_GROUP_TKIP  0x02
#define ZMIPC_WIFI_GROUP_WEP40 0x03
#define ZMIPC_WIFI_GROUP_WEP104 0x04
// pairwise type
#define ZMIPC_WIFI_PAIRWISE_NONE 0x00
#define ZMIPC_WIFI_PAIRWISE_CCMP  0x01
#define ZMIPC_WIFI_PAIRWISE_TKIP  0x02
#define ZMIPC_WIFI_PAIRWISE_CCMP_TKIP 0x03
// authentication type
#define ZMIPC_WIFI_AUTH_NONE 	0x00
#define ZMIPC_WIFI_AUTH_WPA		0x01
#define ZMIPC_WIFI_AUTH_WPA2	0x02
#define ZMIPC_WIFI_AUTH_WEP		0x03
// wep authentication type
#define ZMIPC_WEP_AUTH_NOT		0x00
#define ZMIPC_WEP_AUTH_OPEN		0x01
#define ZMIPC_WEP_AUTH_SHARE	0x02
// wep key format
#define ZMIPC_WEP_KEY_NOT		0x00
#define ZMIPC_WEP_KEY_ASCII		0x01
#define ZMIPC_WEP_KEY_HEX		0x02

// UP response result about exec cmd
#define ZMIPC_RES_SUCCESS		0x01 //except: 0xD7 is 0x00, modify to uniform
#define ZMIPC_RES_FAILURE		0x02 //except: 0xD7 is 0x01

#define ZMIPC_FERR_NEXIST		0x01
#define ZMIPC_FERR_RACED		0x02
#define ZMIPC_FERR_OTHER		0x03
// password error code
#define ZMIPC_FERR_PWFORMAT		0x0010
#define ZMIPC_FERR_PWLENGTH		0x0020

// NAT type and error code
#define ZMIPC_NAT_HOST_UNKOWN	0x00
#define ZMIPC_NAT_ERR_UNKOWN	0x01
#define ZMIPC_NAT_OPENNAT		0x02
#define ZMIPC_NAT_BLOCKED_UDP	0x03
#define ZMIPC_NAT_FIREWALL		0x04
#define ZMIPC_NAT_FC			0x05
#define ZMIPC_NAT_RC			0x06
#define ZMIPC_NAT_PC			0x07
#define ZMIPC_NAT_SN			0x08
// route loop support
#define ZMIPC_RLOOP_UNSUPPORTED	0x00
#define ZMIPC_RLOOP_SUPPORTED	0x01
#define ZMIPC_RLOOP_UNKOWN		0x03

// minor stream level 
#define ZMIPC_MINOR_LEVEL_HIGH	0x01
#define ZMIPC_MINOR_LEVEL_MIDD	0x02
#define ZMIPC_MINOR_LEVEL_LOW	0x03

/* alarm type */
// ftp transfer mode
#define ZMIPC_ALARM_FTP_ACTIVE 	0x01
#define ZMIPC_ALARM_FTP_PASIVE	0x02
// io flag
#define ZMIPC_ALARM_IO_ALLCLOS  0x00
#define ZMIPC_ALARM_IO_OONIOFF  0x01
#define ZMIPC_ALARM_IO_IONOOFF  0x02
#define ZMIPC_ALARM_IO_ALLOPEN 	0x03
// io trigger level
#define ZMIPC_ALARM_IO_LOW 		0x00
#define ZMIPC_ALARM_IO_HIGH		0x01

/* sensor type */
#define ZMIPC_SENSOR_TVP5150	0x00
#define ZMIPC_SENSOR_OV7725		0x01
#define ZMIPC_SENSOR_OV2643		0x02
#define ZMIPC_SENSOR_OV10633	0x03
#define ZMIPC_SENSOR_MT9M034	0x04
#define ZMIPC_SENSOR_OV9712		0x05
#define ZMIPC_SENSOR_GC0328		0x01 // equal to ov7725  
//----------------------------------------------------------------
// down
typedef struct down_data_transfer
{
	struct login_passwd{
		char password[256]; // DES encrytion
		unsigned char len;
	} login_passwd;
	unsigned char data_type;
	struct get_log_file{
		unsigned char type;
		unsigned short size;
	} get_log_file;
	int req_audio_dummy;
	struct send_audio_data{
		unsigned char *data;
		unsigned short len;
	} send_audio_data;
	unsigned char stop_data_type;
	struct req_multichn_data{
		unsigned char type;
		unsigned char chnnl;
	} req_multichn_data;
	unsigned char send_client_type;
}sdown_data_transfer;

union sd_file_content
{
	struct sd_file_list{
		unsigned char type;
		char dirname[16];
	} sd_file_list;
	struct sd_fileinfo_trans{
		char date[16];// 8bytes
		char fname[16];// 6bytes
		unsigned short size; // pack unit size
	} sd_fileinfo_trans;
	struct sd_del_file{
		char date[16];
		char fname[16];
	} sd_del_file;
	unsigned int sd_filedata_packnum;/**< trans pack number */
};
struct ptz_ctrl_content{
	unsigned char action;
	unsigned char step;
	unsigned char speed;
	unsigned char stand_time;
	unsigned char preset_index;
	unsigned char index_a;
	unsigned char index_b;
} ;
struct image_params_operation{
	unsigned char down_action;// when action is 'get',the params don't need

	unsigned char bright;
	short hue; // 255 or -255
	unsigned char saturation;
	unsigned char contrast;
	unsigned char mirror;
	unsigned char wdflag;

	// only for up-res
	unsigned char up_res_status;
	unsigned char up_res_sensor_type;
};
struct video_params_operation{
	unsigned char down_action;
	// only for up-res
	unsigned char up_res_status;
	unsigned char up_res_sensor_type;

	unsigned char stream_type;
	unsigned char resolution;
	unsigned char frate;
	unsigned char gop;
	unsigned char venc_type; // protocol no the param
	unsigned char cbr;
	unsigned short brate;
	unsigned char image_level;
};
struct record_params_operation{
	unsigned char down_action;
	// only for up-res
	unsigned char up_res_status;

	unsigned char flag;// on or off
	unsigned char duration; // unit is min
	unsigned char audio_flag;
};
struct osd_params_operation{
	unsigned char down_action;
	// only for up-res
	unsigned char up_res_status;

	unsigned char time_flag;
	unsigned char osd_flag;
	char osd_info[32];// max:18 ascii char
};
struct network_params_operation{
	unsigned char down_action;
	// only for up-res
	unsigned char up_res_status;

	char ip[16];
	char mask[16];
	char gateway[16];
	char dns1[16];
	char dns2[16];
	unsigned short web_port;
	unsigned short video_port;
	unsigned short rtsp_port;
	unsigned char upnp_flag;
	unsigned char dhcp_flag;
};
struct wifi_params_operation
{
	unsigned char down_action;
	// only for up-res
	unsigned char up_res_status;

	unsigned char flag;
	unsigned char auth_flag;
	unsigned char auth_type;
	unsigned char status;
	unsigned char group_auth_type;
	unsigned char pairwise_type;
	unsigned char wep_auth_type;
	unsigned char wep_key_format;
	unsigned char wep_password[4][48];
	unsigned char password[256];
	unsigned char name[32];
};
struct time_params_operation{
	unsigned char down_action;
	// only for up-res
	unsigned char up_res_status;

	unsigned short year;
	unsigned char month;
	unsigned char mday;
	unsigned char hour;
	unsigned char mins;
	unsigned char secs;
	unsigned char ntp_flag;
	unsigned char tz;
	unsigned char ntp_server[32];
};
struct md_params_operation{
	unsigned char down_action;
	// only for up-res
	unsigned char up_res_status;

	unsigned char flag;
	unsigned char group_flag[6];
	unsigned char group_attr[6];
	unsigned char group_sens[6];
	unsigned char group_delay[6];
	unsigned char group_priority[6];
	struct coordinate{
		unsigned short x[2];
		unsigned short y[2];
	} group_coord[6];
};

/* alarm settings */
struct record_params{
	unsigned char down_action;// down & up both use it
	unsigned char up_res_status; // up-res use
	unsigned char flag;
	unsigned short duration;// second
} ;
struct email_params{
	unsigned char down_action;
	unsigned char up_res_status;

	unsigned char flag;
	unsigned char receiver[5][64];
	unsigned char smtp_server[32];
	unsigned short smtp_port;
	unsigned char safe_type;
	unsigned char check_flag;
	unsigned char smtp_user[64];
	unsigned char smtp_code[64];
};
struct ftp_params{
	unsigned char down_action;
	unsigned char up_res_status;// only up-res
	unsigned char flag;

	unsigned char ftp_server[64];
	unsigned short ftp_port;
	unsigned char down_ftp_user[64];// only down-set
	unsigned char down_ftp_code[64];// only down-set
	unsigned char mode;
	unsigned char ftp_updir[128];
};
struct snapshot_params{
	unsigned char down_action;
	unsigned char up_res_status;

	unsigned char flag;
	unsigned short pics_num;
	unsigned char interval_time;// second
};
struct io_params{
	unsigned char down_action;
	unsigned char up_res_status;

	unsigned char flag;
	unsigned char trig_level;
};
union alarm_params_operation{
	struct record_params record_params;
	struct email_params  email_params;
	struct ftp_params ftp_params;
	struct snapshot_params snapshot_params;
	struct io_params io_params;
};

struct get_nat_type{
	char id[16];
	char stun_domain[32];
};
struct minor_stream_level{
	unsigned char action;
	unsigned char level;
};
struct wifi_params_ap {
	char ssid[32];
	char pwd[32];
	int type;	//
};
struct sdcard_params_operation{
	unsigned char down_action;
	// only for up-res
	unsigned char up_res_status;

	unsigned char umount_flag;// on or off
	unsigned int free_space; // unit is min
	unsigned int total_space;
};
struct dev_version { 
	unsigned char down_action;
	// only for up-res
	unsigned char up_res_status;
	unsigned char version[16];
};
typedef union zmipc_down_content
{
	sdown_data_transfer  data_transfer;
	int query_alarm_status_dummy;
	int reply_alarm_status_dummy;
	union sd_file_content sd_file_content;
	struct ptz_ctrl_content ptz_ctrl_content;
	struct image_params_operation image_params_operation;
	struct video_params_operation video_params_operation;
	struct record_params_operation record_params_operation;
	struct osd_params_operation osd_params_operation;
	struct network_params_operation network_params_operation;
	struct wifi_params_operation wifi_params_operation;
	unsigned char get_wifi_list_dummy;// fixed : 0xff
	unsigned char restore_factory_set_dummy;// fixed : 0xff
	struct time_params_operation time_params_operation;
	struct md_params_operation md_params_operation;
	unsigned char heart_pack_dummy;// fixed : 0xaa
	union alarm_params_operation alarm_params_operation;
	unsigned char reboot_device_dummy;
	unsigned char test_mail_dummy;
	unsigned char change_password[64];
	struct get_nat_type get_nat_type;
	unsigned char dev_display_info[64];// utf-8
	unsigned short io_control_cmd;
	struct minor_stream_level minor_stream_level;
	struct sdcard_params_operation sdcard_params_operation;
	struct dev_version dev_version;
	int dummy;
	struct wifi_params_ap wifi_params_ap; 
}uzmipc_down_content;

// up
struct res_login{
	unsigned char status;
	unsigned char frate;
	unsigned char video_enc;
	unsigned char audio_enc;
	unsigned char cbr;
	unsigned short brate;
} ;
struct res_data{
	unsigned char type;
	unsigned long long timestamp;
	unsigned char frame_seq;
	unsigned char *data;
	unsigned short len;
} ;
struct res_log{
	unsigned char sum;
	unsigned char cur;
	unsigned char type;
	unsigned char *data;
	unsigned short len;
} ;
typedef struct up_data_transfer
{
	struct res_login res_login;
	struct res_data  res_data;
	struct res_log 	 res_log;
	unsigned char res_audio_req;
	unsigned char stop_audio_speech; // fixed : 0xaa
	char send_pc_ocx_ver[16];
	unsigned char res_client_type; // default: 0xff
}sup_data_transfer;

union res_sd_file_content
{
	struct res_sd_file_list{
		unsigned char type;
		unsigned char *name_list;// string: "name1;name2;name3;...;nameN"
		unsigned short size;
	} res_sd_file_list;
	struct res_sd_file_info{
		unsigned int len;
		unsigned int total_pack;
	} res_sd_file_info;
	struct res_sd_file_data{
		unsigned int cur_pack;
		unsigned char *data;
		unsigned int len;
	} res_sd_file_data;
	unsigned char res_sd_del_file;
};
struct res_wifi_list{
	unsigned char mac_addr[32];
	unsigned char auth_type;
	unsigned char signal_value;
	unsigned char group_auth_type;
	unsigned char pairwise_type;
	unsigned char wifi_ssid[64];
};
struct active_alarm_status{
	unsigned char seq;
	unsigned char status;
	unsigned char extra_stat;
};
struct res_ptz_ctrl{
	unsigned char status;
	unsigned char reason;
};
struct wifi_list_info{
	struct res_wifi_list *wifi_list;
	unsigned char size;
};
struct res_mail_test{
	unsigned char result;
	unsigned short err_code;
};
struct res_nat_type{
	unsigned char nat_type;
	unsigned char route_loop;
	unsigned char id[16];
};
struct res_minor_stream{
	unsigned char result;
	unsigned char level;
};
struct res_ap_wifi{
	char ssid[32];
	int sta;
};
typedef union zmipc_up_content
{
	sup_data_transfer data_transfer;
	struct active_alarm_status active_alarm_status;
	union res_sd_file_content res_sd_file_content;
	struct res_ptz_ctrl res_ptz_ctrl;
	struct image_params_operation res_image_params;
	struct video_params_operation res_video_params;
	struct record_params_operation res_record_params;
	struct osd_params_operation res_osd_params;
	struct network_params_operation res_network_params;
	struct wifi_params_operation res_wifi_params;
	struct wifi_list_info res_wifi_list;
	unsigned char res_restore_factory;
	struct time_params_operation res_time_params;
	struct md_params_operation res_md_params;
	union alarm_params_operation res_alarm_params;
	struct res_mail_test res_mail_test;
	struct res_mail_test res_change_password;
	struct res_nat_type  res_nat_type;
	unsigned char res_io_control;
	struct res_minor_stream res_minor_stream;
	struct sdcard_params_operation res_sdcard_params;
	struct dev_version res_dev_version;
	struct res_ap_wifi res_ap_wifi;
	int dummy;
}uzmipc_up_content;

typedef struct zmipc_content
{
	uzmipc_down_content down_content;
	uzmipc_up_content   up_content;
}szmipc_content;

//-----------------------------------------------------------
// 构建报文接口
int zmipc_build_package(eproto_role role, sproto_msg *pmsg, unsigned char *sendbuff, int *len);

// 解析报文接口
int zmipc_parse_package(eproto_role role, sproto_msg *pmsg, unsigned  char *recvbuff, int len);

/** pack stream data to put in circle buff
 * @param[in] type -- ZMIPC_DT_VIDEO ZMIPC_DT_AUDIO
 * @param[in] timestamp the timestamp of frame
 * @param[in] frame_seq the sequence number of frame
 * @param[in] data the source video or audio data pointer
 * @param[in] len the source data length
 * @param[in,out] desbuff the buff to store packed video/audio data
 * @param[in] deslen the desbuff available length
 * @return the packed video/audio data size (>0), or fail 
 */
int pack_raw_stream_data(unsigned char type,unsigned long long timestamp,unsigned char frame_seq,unsigned char *data,unsigned short len, unsigned char *desbuff, int deslen);

/**
 * pack active_alarm_status data to send
 * @param[in] seq io alarm sequence number, from 0 to 255
 * @param[in] type alarm type or status,e.g. io alarm, md alarm,video-loss alarm
 * @param[in] extra alarm extra information
 * @param[in,out] desbuff the buff to store packed data
 * @param[in] deslen the desbuff available length
 * @return the packed data size if > 0, or fail
 * @note the params [type,extra] should be valued according to ZMIPC PROTOCOL
 * document.
 */
int pack_active_alarm_status(unsigned char seq, unsigned char type, unsigned char extra,unsigned char *desbuff, int deslen);

#endif

